table.insert(itemActions,
	function(item, action)
		-- RARE Armors v1.4 - 07.25.08
		-- By Kel, using existing AO and PR functions/code not created by me.
		-- see: dir .. "readme.txt" for information regarding the following variables
		local priority = 6
		local identify = true
		local dump = true

	    if not isRareArmor(item) then
			return false
		elseif action == aPICK and (not item.flags.Identified or isGoodRareArmor(item)) then
			return priority
		elseif action == aIDENT then
			return identify
		elseif action == aSELL and item.flags.Identified and not isGoodRareArmor(item) then
			return true
		elseif action == aDUMP and item.flags.Identified and not isGoodRareArmor(item) then
			return dump
		end
		return false
	end
)


function isRareArmor(item)
   if  (

	  (item.quality == ItemQuality.Rare) and 	-- Rare item
		 			   			    --Item Name---------Weight---Def---Str--Pros/Cons-----------
    (item.baseItem.code == "uui" or -- Dusk Shroud      Light  361-467  77  HiDef,Light,LowStr
    item.baseItem.code == "uea" or  -- Wyrmhide         Light  364-470  84
    item.baseItem.code == "ula" or  -- Scarab Husk      Light  369-474  95
    item.baseItem.code == "utu" or  -- Wire Fleece      Light  375-481 111
    item.baseItem.code == "urs" or  -- Great Hauberk    Light  395-501 118  HiDef,Light,LowStr
    item.baseItem.code == "utp" or  -- Archon Plate     Light  410-524 103  HiDef,Light,LowStr
    item.baseItem.code == "ung" or  -- Diamond Mail     Med    383-484 131  LoDef,Med,OKStr
    item.baseItem.code == "uhn" or  -- Boneweave        Med    399-505 158  HiDef,Med,LowStr
    item.baseItem.code == "upl" or  -- Balrog Skin      Med    410-517 165
	item.baseItem.code == "uld" or  -- Kraken Shell     Med    417-523 174
    item.baseItem.code == "uth" or  -- Lacquered Plate  Med    433-541 208  OKDef,Med,HiStr
    item.baseItem.code == "uar" or  -- Sacred Armor     Med    487-600 232  HiDef,Med,HiStr
	item.baseItem.code == "ult" or	-- Hellforge Plate  Heavy  421-530 196  LoDef,Heavy,HiStr.Use Kraken
    item.baseItem.code == "ucl" or  -- Loricated Mail   Heavy  390-496 149  LoDef,Heavy,LowStr
   	item.baseItem.code == "uul"     -- Shadow Plate     Heavy  446-557 230  LoDef,Heavy,HiStr.Use Sacred
    -- or item.baseItem.code == "xtp"  -- Mage Plate    Light  225-261  60  Exceptional - LLD/Upping
	  )
	
	) then
	  return true
  end
  return false
end


function isGoodRareArmor(item)
     local def, life, mana, str = false, false, false, false
     local fhr, dr, req, repair, dblvl = false, false, false, false, false
     local dualres, trires, allres = false, false, false
	 local goodmod, greatmod = false, false
	 local twosox = false

     dualres = hasRes(item, 28, 2) 	-- 2 resists 28-30%
     trires = hasRes(item, 25, 3) 	-- 3 resists 26-30%
     allres = hasRes(item, 15, 4) 	-- 4 resists 15-30%
	 twosox = hasCertainSockets(item, "2")


	  	for i = 0, item.mods:size() - 1 do
 	  	if item.mods[i].Stat.Type == StatType.DefensePercent then
				if item.mods[i].Value >= 190 then -- 190-200%Def->greatmod
					greatmod = true
				elseif item.mods[i].Value >= 140 then -- 140-189%Def->goodmod
					goodmod = true
				elseif item.mods[i].Value >= 70 then -- 70-139%Def->def
					def = true
				end
	 	elseif item.mods[i].Stat.Type == StatType.MaxLife then
				if item.mods[i].Value >= 51 then -- 51-60 Life->greatmod
					greatmod = true
				elseif item.mods[i].Value >= 41 then -- 41-50 Life->goodmod
					goodmod = true
				elseif item.mods[i].Value >= 21 then -- 21-30 Life->life
					life = true
				end
		elseif item.mods[i].Stat.Type == StatType.Strength then
				if item.mods[i].Value >= 19 then -- 19-20 Str->greatmod
					greatmod = true
				elseif item.mods[i].Value >= 14 then -- 14-18 Str->goodmod
					goodmod = true
				elseif item.mods[i].Value >= 10 then -- 10-13 Str->str
					str = true
				end
		elseif item.mods[i].Stat.Type == StatType.FasterHitRecovery then
				if item.mods[i].Value == 24 then -- 24fhr->greatmod
					greatmod = true
				elseif item.mods[i].Value >= 10 then -- 10-17fhr->fhr
					fhr = true
				end
		elseif (item.mods[i].Stat.Type == StatType.MaxMana and
			item.mods[i].Value >=35) then -- +30-40 Mana-->mana
					mana = true
		elseif (item.mods[i].Stat.Type == StatType.DamageReduction and
			item.mods[i].Value >=6) then -- 5-7 Integer DR -Think free Sol.
					dr = true
		elseif (item.mods[i].Stat.Type == StatType.LowerRequirementsPercent and
			item.mods[i].Value >=20) then -- -20-30% Lower Reqs. Good for Heavy or Merc
					req = true
		elseif (item.mods[i].Stat.Type == StatType.ReplenishDurability and
            item.flags.Ethereal) then  --  Eth + Auto-Repair Mod.
        			repair = true
		elseif (item.mods[i].Stat.Type == StatType.ArmorPerLevel and
            item.mods[i].PerLevel >=3) then -- 3-4 def/lvl only (Faithful)
			dblvl = true
    end
end

-- Returns are VERY inclusive for testing. Will optimize in the next release.

return (
        (def and (life or mana or str or fhr or dr or dualres or req or onesox or dblvl)) or -- 81-200%ED & other mod
		(dualres and (life or mana or str or fhr or dr or req or onesox or dblvl)) or -- Dual res of 11-30% & other mod
		(life and (str or fhr or dualres or req or onesox or dblvl)) or  -- 51-60 Life & other mod
		(goodmod and (onesox or twosox or def or life or mana or str or dr or dualres or req)) or
		trires or -- 3 resists of 12-30%
		allres or -- All resists of 10-30%
		repair or -- Eth+auto-repair mod testing.
		greatmod
        )
    end

-- DESIRABLE AFFIXES USED IN THIS PICKIT
--  Prefixes     ----------------------
--	Holy	     81%-100% Defense
--	Godly	     101%-200% Defense
--  Faithful     Says 24/Level, but 4 def + 0.5 def/Level (3.5-346.5 Defense)
--  Dragon's     31-40 to Mana
--  Cobalt	     21-30% Cold Resist
-- 	Garnet	     21-30% Fire Resist
--  Coral	     21-30% Lightning Resist
-- 	Jade	     21-30% Poison Resist
--  Mechanic's   1-2 Sockets
----Suffixes----------------------------
--  Life	     4-7 Integer Damage Reduction
--  Accuracy	 6-9 to Dexterity (kinda sucks)
--  Equilibrium  17% FHR
--  Stability    24% FHR
--	Mammoth	     31-40 to Life
--	Colossus	 41-60 to Life
--  Ease	     -20% Requirements
--  Simplicity	 -30% Requirements
--  the Giant	 10-15 to Strength
--  the Titan	 16-20 to Strength
--  Self-Repair	 Repair 1 Durability-33sec
--  Restoration	 Repair 1 Durability-20sec